<?php

FLEA::loadClass('FLEA_Db_TableDataGateway');

class Table_Permissions extends FLEA_Db_TableDataGateway
{
	var $primaryKey = 'permission_id';
	
	/**
	 * 定义permissions表与permission_groups表的belongsTo关联
	 * 即每一个权限都属于唯一一个权限组
	 *
	 * @var array
	 */
	var $belongsTo = array(
         array(
             'tableClass'  => 'Table_PermissionGroups',
             'foreignKey'  => 'permission_group_id',
             'mappingName' => 'permission_group'
         ),
     );
     
    var $manyToMany = array(
    	// 与权限表多对多关联
    	array(
	        'tableClass'  => 'Table_Roles',
	        'mappingName' => 'roles',
	        'joinTableClass'   => 'Table_RolesHasPermissions',
    	),
    );

	function Table_Permissions($params = null){  
		$this->tableName = FLEA::getAppInf('WebsetupTablePrefix').'permissions';  
		parent::FLEA_Db_TableDataGateway($params);  
	}
    
}

?>